Skip to content

perf: enable Android emulator Quick Boot - #359

Merged
janicduplessis merged 4 commits into
mainfrom
@janic/issue-284-emulator-snapshots
Sep 5, 2026
Merged

perf: enable Android emulator Quick Boot#359
janicduplessis merged 4 commits into
mainfrom
@janic/issue-284-emulator-snapshots

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Description

Owned Android AVDs cold-boot on every restart because Stim disables Quick Boot loading and saving. The measurements in #284 found about 22 seconds of avoidable startup time.

The flags were added in PR #93 to reduce AVD storage (original commit), before Stim measured and configured owned-AVD userdata.

Fixes #284.

Solution

Use Android Emulator's default Quick Boot policy for owned AVDs. Displayless Linux retains disabled snapshots because its software renderer makes them unreliable. New or invalid snapshots fall back to a cold boot; Android invalidates snapshots after emulator, system-image, or AVD-setting changes (Android documentation).

Teardown preserves the bounded guest-write flush from #357 and waits for the emulator process to exit after saving its snapshot. The 60-second shutdown budget includes sync and the adb command. Invalid PID locks, unresolved live emulators, shutdown timeouts, and pre-deletion restarts prevent deletion and keep the ownership record. Windows can expose an empty PID file before writing its PID, so a present invalid lock refuses cleanup (upstream lock implementation).

The storage policy keeps one automatic snapshot. New owned AVDs retain the configurable 8 GiB default data partition; existing AVDs keep their size. worktree remove deletes the whole AVD, and gc reports stale or orphaned owned-AVD sizes. The guide and benchmark control prompt describe the same policy.

Test plan

  • 288 focused Android, teardown, ownership, and guide tests passed. Shutdown deadline and invalid-lock regressions both failed when their fixes were temporarily removed.
  • Format, lint, build, typecheck, knip, website build/typecheck, all 3,662 unit tests, and 24 end-to-end tests passed.
  • Created an isolated Stim-owned ARM64 API 34 AVD with Android Emulator 35.6.11. The first snapshot-enabled cold boot took 13.5 seconds; centralized shutdown waited 2.5 seconds for process exit and saved default_boot. The next boot took 5.6 seconds, logged a successful snapshot load, and restored a marker written immediately before shutdown. These are one local run's observations, not a benchmark series.
  • Centralized teardown then deleted that AVD and cleared its isolated ownership record. Its measured footprint was 2.46 GiB before deletion. No pre-existing device was changed.

@janicduplessis
janicduplessis marked this pull request as ready for review September 5, 2026 06:21
@janicduplessis
janicduplessis merged commit e6ddc3a into main Sep 5, 2026
5 checks passed
@janicduplessis
janicduplessis deleted the @janic/issue-284-emulator-snapshots branch September 5, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android emulators always boot with snapshots disabled, costing about 22 s per reboot

1 participant